/***********************************************************************
 * Module:  ControlTaskToPointService.java
 * Author:  Administrator
 * Purpose: Defines the Class ControlTaskToPointService
 ***********************************************************************/

package ishitong.rvims.control.service;

import ishitong.rvims.control.persistence.ControlTaskToPointMapper;
import java.util.HashMap;
import java.util.List;
import ishitong.rvims.domain.control.ControlPoint;
import ishitong.rvims.domain.control.ControlTask;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/** @pdOid 7516a235-9d68-43b5-8765-adc2b3e98c53 */
@Service
public class ControlTaskToPointService {
   /** @pdOid 3c447162-506e-4245-a6bd-1333e4841a15
       @pdRoleInfo migr=yes name=ControlTaskToPointMapper assc=association8 */
   @Autowired
   private ControlTaskToPointMapper controlTaskToPoint;
   
   /** @param controlTaskId
    * @pdOid 94efb2d7-220d-43c1-9e2e-144126d0e8a7 */
   public void deleteControlPointByControlTaskId(String controlTaskId) {
      // TODO: implement
    controlTaskToPoint.deleteControlPointByControlTaskId(controlTaskId);
   }
   
   /** @param controlTaskIds 
    * @param controlPointIds
    * @pdOid 0904e769-d641-4853-b205-5dd910b22a6f */
   public int updateControlTaskToPoint(String[] controlTaskIds, String[] controlPointIds) {
      // TODO: implement
   HashMap<String,Integer> cphm = new HashMap<String,Integer>();
   for(int i = 0 ; i < controlTaskIds.length ; i ++)
   {
    for (int j = 0 ; j < controlPointIds.length ; j ++)
    {
     cphm.put("ID", Integer.parseInt(controlTaskIds[i]));
     cphm.put("T_C_ID", Integer.parseInt(controlPointIds[j]));
     controlTaskToPoint.insertControlTaskToPoint(cphm);
    }
   }
      return 0;
   }
   
   /** public int updateControlTaskToPoint(ControlTask controlTask){
    * 	   List<ControlPoint> listControlPoint = controlTask.getListControlPoint();
    * 	   HashMap<String,Integer> cphm = new HashMap<String,Integer>();
    * 	   for(ControlPoint cp : listControlPoint)
    * 	   {
    * 		  cphm.put("ID", Integer.parseInt(controlTask.getId()));
    * 		  cphm.put("T_C_ID", Integer.parseInt(cp.getId()));
    * 		  controlTaskToPoint.insertControlTaskToPoint(cphm);
    * 	   }
    * 	   return 0;
    *    }
    * 
    * 
    * @param controlTaskId
    * @pdOid 777231fd-8c5f-4a15-9e95-f0d88284f49e */
   public List<ControlPoint> findControlPointByControlTaskId(String controlTaskId) {
      // TODO: implement
      return controlTaskToPoint.selectControlPointByControlTaskId(controlTaskId);
   }

}